package 力扣._100049_美丽塔1;

import java.util.List;

public class Solution2 {
    public long maximumSumOfHeights(List<Integer> maxHeights) {
        //每个值暴力
        long max=-1;
        for (int j = 0; j < maxHeights.size(); j++) {
            //向两边单调不增
            long sum = maxHeights.get(j);
            //向左
            long last = sum;
            for (int i = j - 1; i >= 0; i--) {
                if (maxHeights.get(i) >= last)
                    sum += last;
                else {
                    last = maxHeights.get(i);
                    sum += last;
                }
            }
            //向右
            last = maxHeights.get(j);
            for (int i = j + 1; i < maxHeights.size(); i++) {
                if (maxHeights.get(i) >= last)
                    sum += last;
                else {
                    last = maxHeights.get(i);
                    sum += last;
                }
            }
            max=Math.max(max,sum);
        }

        return max;
    }
}
